﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Intorise.LLPM.Model;

namespace LlpmApp
{
    /// <summary>
    /// Login.xaml 的交互逻辑
    /// </summary>
    public partial class Login : Window
    {
        public Login()
        {
            InitializeComponent();
            ImageBrush b = new ImageBrush();
            b.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/Hydrangeas.jpg"));
            b.Stretch = Stretch.Fill;
            this.border.Background = b;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.textBox1.Focus();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (this.textBox1.Text != "" && this.passwordBox1.Password != "")
            {
                User user = User.Login(this.textBox1.Text, this.passwordBox1.Password);
                if (user == null)
                {
                    MessageBox.Show("用户名或密码错误！");
                }
                else
                {
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    this.Close();
                }
            }
        }
    }
}
